#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

class Solution {
public:

    typedef pair<int, int> PII;

    int dx[4] = { 0 , 0 , 1 , -1 };
    int dy[4] = { 1, -1 , 0 , 0 };

    vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int sc, int color) {
        if (image[sr][sc] == color)
            return image;

        int prev = image[sr][sc];
        queue<PII> que;
        que.push({ sr,sc });

        while (!que.empty())
        {
            auto [a, b] = que.front();
            que.pop();

            image[a][b] = color;

            for (int i = 0; i < 4; ++i)
            {
                int x = a + dx[i], y = b + dy[i];
                if (x >= 0 && x < image.size() && y >= 0 && y <= image[0].size()
                    && image[x][y] == prev)
                    que.push({ x,y });
            }

        }

        return image;
    }
};

int main() 
{

	return 0;
}